#include <stdio.h>

float factorial(int n);

int main(int argc, char *argv[]) {
	float e = 0;
	float c = 0;

	int i = 0;
	do {
		c = (float)1 / factorial(i);
		printf("第%d项：%.5f\n", i+1, c);
		e = e + c;
		i++;
	} while (c > 0.0001);

	printf("e = %.5f\n", e);

}

float factorial(int n) {
	if (n == 0 || n == 1) {
		return 1;
	} else {
		return n * factorial(n-1);
	}
}
